/**
 * Created by qupen on 2016/9/29.
 */

function chooseLanguage(language) {
    var uri = window.location.href;
    if ((uri.indexOf("lang=zh") > -1) || (uri.indexOf("lang=en") > -1)) {
        uri = uri.replace(/\?lang=zh/, '').replace(/\?lang=en/, '').replace(/&lang=zh/, '').replace(/&lang=en/, '');
    }
    var url = uri.split("#");
    if (uri.indexOf("?") < 0) {
        window.location.href = url[0] + "?lang=" + language + "#" + url[1];
    } else {
        window.location.href = url[0] + "&lang=" + language + "#" + url[1];
    }
}

function verifyEmail(hint1, hint2) {
    $("#mailTips").attr("class", "").html("");
    var regexp = /^[A-Z_a-z0-9-\.]+@([A-Z_a-z0-9-]+\.)+[a-z0-9A-Z]{2,4}$/;
    var email = $.trim($("#mail").val());
    if (email == "") {
        $("#mailTips").attr("class", "no").html(hint1);
        return false;
    } else if (!regexp.test(email)) {
        $("#mailTips").attr("class", "no").html(hint2);
        return false;
    }
    $("#mailTips").attr("class", "yes").html("");
    return true;
}

//验证手机
function verifyMobile(hint1) {
    $("#phoneTips").attr("class", "").html("");
    var regexp = /^1\d{10}$/;
    var mobile = $.trim($("#telephone").val());
    var phone = /^\d{3,4}-\d{7,8}$/;
    if (mobile == "") {
        return true;
    } else if (!regexp.test(mobile) && !phone.test(mobile)) {
        $("#phoneTips").attr("class", "no").html(hint1);
        return false;
    }
    $("#phoneTips").attr("class", "yes").html("");
    return true;
}

function ajaxVerifyTenant(type, _this, hint1, hint2, hint3, hint4, hint5) {
    var param = _this.value;
    if (param == "") {
        if (type == "tenant_key") {
            $("#keyTips").attr("class", "no").html(hint1);
            return;
        } else if (type == "tenant_name") {
            $("#userNameTips").attr("class", "no").html(hint2);
            return;
        }
    }
    if (type == "tenant_key") {
        $("#keyTips").attr("class", "load").html(hint3);
    } else if (type == "tenant_name") {
        $("#userNameTips").attr("class", "load").html(hint3);
    }
    $.ajax({
        url: "/admin/api/v1/tenant/check",
        type: "get",
        data: {type: type, param: param},
        success: function (data) {
            if (data.data == null) {
                if (type == "tenant_key") {
                    $("#keyTips").attr("class", "yes").html("");
                } else if (type == "tenant_name") {
                    $("#userNameTips").attr("class", "yes").html("");
                }

            } else {
                if (type == "tenant_key") {
                    $("#keyTips").attr("class", "no").html(hint4);
                } else if (type == "tenant_name") {
                    $("#userNameTips").attr("class", "no").html(hint5);
                }
            }
        },
        error: function (e) {
            console.log(e);
        }
    });
}
function ajaxVerifyUser(_this, hint1, hint2, hint3) {
    var param = _this.value;
    if (param == "") {
        $("#userNameTip").attr("class", "no").html(hint1);
        return;
    }
    $("#userNameTip").attr("class", "load").html(hint2);
    $.ajax({
        url: "/admin/api/v1/user/checkName",
        type: "get",
        data: {userName: param},
        success: function (data) {
            if (!data.data) {
                $("#userNameTip").attr("class", "yes").html("");
            } else {
                $("#userNameTip").attr("class", "no").html(hint3);
            }

        },
        error: function (e) {
            console.log(e);
        }
    });
}

function getKeyByUrl() {
    var pathname = window.location.pathname;
    return pathname.split("/")[2];
}

function changeClick() {
    return $("#avatar").click();
}

//获取数据:一台机床的状态时间统计的历史趋势
function oneDeviceStateBarChart(param) {
    $.ajax({
        url: "/partner/{tenant}/api/v1/device/mtStateOne".replace("{tenant}", getKeyByUrl()),
        type: "get",
        data: param,
        success: function (data) {
            createOneDeviceStateBarChart(data.data);
        },
        error: function (e) {
            console.log(e);
        }
    });
}

//24 小时 进度条
function twentyFourHoursLine(deviceId) {
    if ($("#hoursTimeLine").val().length == 0) {
        $("#hoursTimeLine").val(dateFormat(new Date()));
    }
    var url;
    if ($('#hoursTimeLine').val() != dateFormat(new Date())) {
        url = "/partner/{tenant}/api/v1/device/periodsoftime".replace("{tenant}", getKeyByUrl());
    } else {
        url = "/partner/{tenant}/api/v1/device/periodsoftimeByCalculate".replace("{tenant}", getKeyByUrl());
    }
    $.ajax({
        url: url,
        type: "get",
        data: {
            deviceId: deviceId,
            startTime: $('#hoursTimeLine').val()
        },
        success: function (data) {
            $("#timeLine").html('');
            $.each(data.data, function (index, map) {
                var $div = $("<div></div>"), color, onmouseover;
                if (map.state == 0) {
                    color = "#d7d7cd";
                    onmouseover = "showInfo(0,this)";
                } else if (map.state == 1) {
                    color = "#aaaa96";
                    onmouseover = "showInfo(1,this)";
                } else {
                    color = "#73645a";
                    onmouseover = "showInfo(-1,this)";
                }
                console.log((map.minute / (14.4 * 60)).toFixed(8) + "%");
                $div.attr("style", "background-color:" + color + ";width:" + (map.minute / (14.4 * 60)).toFixed(8) + "%;display:inline-block;height:40px;position:relative")
                    .attr("onmouseover", onmouseover)
                    .attr("onmouseout", "removeInfo(this);");
                $("#timeLine").append($div);
            });
        },
        error: function (e) {
            console.log(e);
        }
    })
}

function secondToDate(second) {
    var time = "";
    if (second == 0) {
        return 0;
    }
    if (second >= 3600) {
        time += parseInt(second / 3600) + "h ";
        second = second % 3600;
    }
    if (second >= 60) {
        time += parseInt(second / 60) + "m ";
        second = second % 60;
    }
    if (second > 0 && second < 60) {
        time += parseInt(second) + "s";
    }
    return time;
}

//时间加减
function dateAddSubtract(date, day) {
    var time = date.valueOf() + (day) * 3600 * 24 * 1000;
    if (time < new Date("2016-11-1").valueOf()) {
        return new Date("2016-11-1");
    }
    return new Date(time);
}

//获取开始时间和结束时间（字符串格式2016-11-10）
function getPeriodOfTime(dom, prefix, currentDate) {
    var data = {};
    if (prefix == null || $("#" + prefix + "_week").hasClass('btn-selector')) {   //说明为默认或week  7天
        data["startTime"] = dateFormat(dateAddSubtract(currentDate, -6));
        data["endTime"] = dateFormat(currentDate);
    } else if ($("#" + prefix + "_month").hasClass('btn-selector')) {  //month
        data["startTime"] = dateFormat(dateAddSubtract(currentDate, -30));
        data["endTime"] = dateFormat(currentDate);
    } else if ($("#" + prefix + "_year").hasClass('btn-selector')) {   //year
        data["startTime"] = dateFormat(dateAddSubtract(currentDate, -364));
        data["endTime"] = dateFormat(currentDate);
    } else {      //选择了自定义日期事件
        data["startTime"] = $("#" + prefix + "_start_time").val();
        data["endTime"] = $("#" + prefix + "_end_time").val();
    }
    return data;
}

//时间转成2016-11-11       参数:为时间类型
function dateFormat(date) {
    var stringDate = "";
    var year = date.getFullYear();
    var month;
    if (date.getMonth() + 1 < 10) {
        month = "0" + (date.getMonth() + 1);
    } else {
        month = date.getMonth() + 1;
    }
    var day = date.getDate();
    stringDate = year + "-" + month + "-" + day;
    return stringDate;
}

//时间转成2016-11-11 11:11：11
function dateTimeFormat(date) {
    var stringTime;
    var hours, minutes, seconds;
    if (date.getHours() < 10) {
        hours = "0" + date.getHours();
    } else {
        hours = date.getHours();
    }
    if (date.getMinutes() < 10) {
        minutes = "0" + date.getMinutes();
    } else {
        minutes = date.getMinutes();
    }
    if (date.getSeconds() < 10) {
        seconds = "0" + date.getSeconds();
    } else {
        seconds = date.getSeconds();
    }
    stringTime = hours + ":" + minutes + ":" + seconds;
    return stringTime;
}

//时间转换 2016-12-21 00:00:00 --> 2016,12,21,0,0,0
function dateFormatUTCToComma(date) {
    var commaDate = "";
    var fullYear = date.getFullYear();
    var month = date.getMonth();
    var day = date.getDate();
    var hours = date.getHours();
    var minutes = date.getMinutes();
    var seconds = getSeconds();
    fullYear + "," + month + "," + day + "," + hours + "," + minutes + "," + seconds;
}


/*
 * title:标题
 * contentElement:要显示的div
 * onpresent:哪个div触发的事件
 * prefix:前缀--获取数据
 * */
function showPopup(title, contentElement, onpresent, prefix) {
    $('.popup-mask').remove();
    var $mask = $("<div></div>").addClass("popup-mask");
    var $wrapper = $("<div></div>").addClass('popup-wrapper');
    var $contentWrapper = $('<div></div>').addClass('popup-content');
    var $closeButton = $('<a></a>')
        .attr('href', "javascript:hidePopup()")
        .attr('id', 'close-button')
        .addClass('popup-close-button')
        .append($('<i></i>').addClass("fa fa-times"));
    $wrapper.append($contentWrapper.append($closeButton).append($(contentElement)));
    $mask.append($wrapper);
    $('body').append($mask);
    $(contentElement).removeClass('hidden');

    $wrapper.css({
        right: ($(".content-wrapper-bg").width() - $wrapper.width()) / 2 + 'px',
        top: ($(window).height() - $wrapper.height()) / 2 + 'px'
    });

    $("#contrast_select_sure").attr("data-id", onpresent);
    $("#contrast_select_sure").attr("data-prefix", prefix);
}

function hidePopup() {
    var content = $(".popup-mask").find('.popup-content').children()[1];
    $('body').append($(content).addClass('hidden'));
    $('.popup-mask').remove();
}

//验证设备ID(UniqueId)
function verifyUniqueId(_this, hint1, hint2) {
    var uniqueId = $(_this).val();
    if (uniqueId.trim() == "") {
        return;
    }
    $.ajax({
        url: "/partner/{tenant}/api/v1/device/getByUniqueId".replace("{tenant}", getKeyByUrl()),
        data: {uniqueId: uniqueId},
        success: function (data) {
            if (data.data == null) {
                $("#uniqueIdTips").attr("class", "yes").html(hint1);
            } else {
                $("#uniqueIdTips").attr("class", "no").html(hint2);
            }
        }
    })
}

function BYLoadingToast(message, callback) {
    var $loadingToast = $("<div></div>").addClass("by-loading-toast").append("<div class='by-mask-transparent'></div>");

    var $toast = $("<div></div>").addClass("by-toast");
    var $loading = $("<div></div>").addClass("by-loading");
    for (var i = 0; i < 12; i++) {
        var classStr = "by-loading-leaf-" + i;
        $loading.append($("<div></div>").addClass("by-loading-leaf ").addClass(classStr))
    }
    $toast.append($loading).append("<p class='by-toast-content' style='font-size: 14px'>" + message + "</p>");
    $loadingToast.append($toast);
    $(document.body).append($loadingToast);
    if (callback) {
        var dtd = $.Deferred();
        callback(dtd);
        dtd.done(function () {
            $('.by-loading-toast').hide().remove();
        });
    }
}

Date.prototype.formatXl = function () {
    return this.getFullYear()
        + '-' + ((this.getMonth() + 1) >= 10 ? '' : '0') + (this.getMonth() + 1)
        + '-' + (this.getDate() >= 10 ? '' : '0') + this.getDate()
        + ' ' + (this.getHours() >= 10 ? '' : '0') + this.getHours()
        + ':' + (this.getMinutes() >= 10 ? '' : '0') + this.getMinutes()
        + ':' + (this.getSeconds() >= 10 ? '' : '0') + this.getSeconds();
};

Date.prototype.formatTime = function () {
    return (this.getHours() >= 10 ? '' : '0') + this.getHours()
        + ':' + (this.getMinutes() >= 10 ? '' : '0') + this.getMinutes()
        + ':' + (this.getSeconds() >= 10 ? '' : '0') + this.getSeconds();
};

//取出html标签
function removeHtmlTag(str) {
    var s;
    if (str !== null && str !== undefined) {
        s = str.replace(/<\/?[^>]*>/g, '')
    }
    return s;
}

function removeSpace(str) {
    var s;
    if (str !== null && str !== undefined) {
        s = str.replace("", '')
    }
    return s;
}

function removeTrimSpace(str) {
    var s;
    if (str !== null && str !== undefined) {
        s = String.trim(str)
    }
    return s;
}

function loadChartHeaders() {
    $.ajax({
        url: "/partner/{tenant}/api/v1/device/getChartHeaders".replace("{tenant}", getKeyByUrl()),
        type: "get",
        success: function (data) {
            var models = data.data.models;
            var types = data.data.types;
            var groups = data.data.groups;
            var lines = data.data.lines;

            $.each(models, function (index, model) {
                $("#model option:first").after($("<option></option>").text(model.device_model))
            });
            $.each(types, function (index, type) {
                $("#type option:first").after($("<option></option>").text(type.device_type))
            });
            $.each(groups, function (index, group) {
                $("#group option:first").after($("<option></option>").text(group.group))
            });
            $.each(lines, function (index, line) {
                $("#line option:first").after($("<option></option>").text(line.line))
            })

        },
        error: function (e) {
            console.log(e);
        }
    })
}

function searchClick() {
    var model = $("#model").find("option:selected").data("id") !== undefined ? "" : $("#model").find("option:selected").text();
    var type = $("#type").find("option:selected").data("id") !== undefined ? "" : $("#type").find("option:selected").text();
    var group = $("#group").find("option:selected").data("id") !== undefined ? "" : $("#group").find("option:selected").text();
    var line = $("#line").find("option:selected").data("id") !== undefined ? "" : $("#line").find("option:selected").text();
    BYLoadingToast("loading...", function (dtd) {
        $.ajax({
            url: "/partner/{tenant}/api/v1/device/search".replace("{tenant}", getKeyByUrl()),
            type: "post",
            contentType: "application/json",
            data: JSON.stringify({
                model: model,
                type: type,
                group: group,
                line: line
            }),
            success: function (data) {
                if (data.data.length === 0) {
                    dtd.resolve();
                    swal("无符合结果!", "", "warning");
                } else {
                    $("#device").html("");
                    dtd.resolve();
                    $("#device").append($("<option></option>").attr({
                        "data-option": "first"
                    }).text("请选择"));

                    $.each(data.data, function (index, device) {
                        $("#device").append($("<option></option>").attr({
                            "data-id": device.device_id,
                            "data-type": device.device_type,
                            "data-model": device.device_model
                        }).text(device.device_unique_id));
                    });
                }
            },
            error: function (e) {
                dtd.resolve();
                console.log(e);
            }
        })
    })
}

function loadAlertData() {
    var model = $("#deviceModel").val();
    var type = $("#deviceType").val();
    var group = $("#deviceGroup").find("option:selected").data("id") !== undefined ? "" : $("#deviceGroup").find("option:selected").text();
    var line = $("#deviceLine").find("option:selected").data("id") !== undefined ? "" : $("#deviceLine").find("option:selected").text();

    $.ajax({
        url: "/partner/{tenant}/api/v1/device/search".replace("{tenant}", getKeyByUrl()),
        type: "post",
        contentType: "application/json",
        data: JSON.stringify({
            model: model,
            type: type,
            group: group,
            line: line
        }),
        success: function (data) {
            if (data.data.length === 0) {
                swal("无符合结果!", "", "warning");
            } else {
                $("#device_checkbox").empty();
                $.each(data.data, function (index, device) {
                    if (device.device_id != $("#device").find("option:selected").data("id")) {
                        var $div = $("<div></div>").addClass("col-md-6 sie-flex-item item-access").attr("onclick", "addcheckd(this)").append(
                            $("<a>").addClass("sie-checkbox checked").attr("data-id", device.device_id).attr("style", "margin-left: 15px;")).append(
                            $("<span></span>").attr("style", "margin-left: 5px;").text(device.device_unique_id));
                        $("#device_checkbox").append($div);
                    }
                });
                console.log(data);
            }
        },
        error: function (e) {
            console.log(e);
        }
    })
}
function loadAlertLineAndGroupData() {
    var model = $("#deviceModel").val();
    var type = $("#deviceType").val();
    $.ajax({
        url: "/partner/{tenant}/api/v1/device/linesAndGroups".replace("{tenant}", getKeyByUrl()),
        type: "get",
        data: {
            model: model,
            type: type
        },
        success: function (data) {
            $("#deviceGroup").html("");
            $("#deviceGroup").append($("<option>全部</option>").attr("data-id", "1"));
            $.each(data.data.groups, function (index, group) {
                $("#deviceGroup").append($("<option></option>").text(group.group));
            });
            $("#deviceLine").html("");
            $("#deviceLine").append($("<option>全部</option>").attr("data-id", "1"));
            $.each(data.data.lines, function (index, line) {
                $("#deviceLine").append($("<option></option>").text(line.line));
            });
        },
        error: function (e) {
            console.log(e);
        }
    })
}

function adminLoadTenantForChart() {
    $.ajax({
        url: "/admin/device/getAllTenantNames",
        type: 'get',
        success: function (data) {
            if (data.data == null) {
                return;
            }
            $('#select_tenant').append($("<option></option>").attr("data-option", "first").attr("selected", "selected").text("请选择"));
            $.each(data.data, function (index, result) {
                var $option = $("<option></option>").attr("data-tenantid", result.tenant_id).attr("data-tenantkey", result.tenant_key).text(result.tenant_name);
                $('#select_tenant').append($option);
            });
        },
        error: function (data) {
            console.log(data);
        }
    });
}

function adminLoadDeviceOtherForChart() {
    var $selected = $("#select_tenant").find("option:selected");
    var data = {};
    data["tenantId"] = $selected.data("tenantid");

    $.ajax({
        url: "/admin/device/getAllHeadersByTenantId",
        type: "get",
        data: data,
        success: function (data) {
            if (data.result != "SUCCESS" || data.data == null) {
                return;
            }
            var models = data.data.models;
            var types = data.data.types;
            var groups = data.data.groups;
            var lines = data.data.lines;

            $("#model").html("");
            $("#model").append($("<option></option>").attr("data-id", 1).text("全部"));
            $.each(models, function (index, model) {
                $("#model option:first").after($("<option></option>").text(model.device_model))
            });

            $("#type").html("");
            $("#type").append($("<option></option>").attr("data-id", 1).text("全部"));
            $.each(types, function (index, type) {
                $("#type option:first").after($("<option></option>").text(type.device_type))
            });

            $("#group").html("");
            $("#group").append($("<option></option>").attr("data-id", 1).text("全部"));
            $.each(groups, function (index, group) {
                $("#group option:first").after($("<option></option>").text(group.group))
            });

            $("#line").html("");
            $("#line").append($("<option></option>").attr("data-id", 1).text("全部"));
            $.each(lines, function (index, line) {
                $("#line option:first").after($("<option></option>").text(line.line))
            });
            $(".sie-other-condition").attr("disabled", false);
            adminSearchClick();
        },
        error: function (data) {
            console.log(data);
        }
    });
}

function adminSearchClick() {
    var tenantId = $("#select_tenant").find("option:selected").data('tenantid');
    var type = $("#type").find("option:selected").data("id") !== undefined ? "" : $("#type").find("option:selected").text();
    var model = $("#model").find("option:selected").data("id") !== undefined ? "" : $("#model").find("option:selected").text();
    var group = $("#group").find("option:selected").data("id") !== undefined ? "" : $("#group").find("option:selected").text();
    var line = $("#line").find("option:selected").data("id") !== undefined ? "" : $("#line").find("option:selected").text();
    BYLoadingToast("loading...", function (dtd) {
        $.ajax({
            url: "/admin/device/search",
            data: {
                tenantId: tenantId,
                type: type,
                model: model,
                group: group,
                line: line
            },
            success: function (data) {
                if (data.data.length === 0) {
                    dtd.resolve();
                    swal("无符合数据", "", "warning");
                } else {
                    dtd.resolve();
                    $('#select_device').html("");
                    $('#select_device').append($("<option></option>").attr("data-option", "first").attr("selected", "selected").text('请选择'));
                    $.each(data.data, function (index, result) {
                        var $option = $("<option></option>").attr("data-deviceid", result.device_id).attr("data-devicename", result.device_unique_id).attr("data-devicetype", result.device_type).attr("data-devicemodel", result.device_model).text(result.device_unique_id);
                        $('#select_device').append($option);
                    });
                }
            },
            error: function (e) {
                dtd.resolve();
                console.log(e);
            }
        });
    });
}

function loadAdminAlertLineAndGroupData() {
    var model = $("#deviceModel").val();
    var type = $("#deviceType").val();
    $.ajax({
        url: "/admin/device/getAlertData",
        type: "get",
        data: {
            model: model,
            type: type
        },
        success: function (data) {
            console.log("----------------------1-----------------------------------");
            console.log(new Date());
            console.log("-----------------------------------------------------------------------");
            $("#tenants").html("");
            $("#tenants").append($("<option>全部</option>").attr("data-id", "1"));
            $.each(data.data.mtids, function (index, tenant) {
                $("#tenants").append($("<option></option>").attr("value",tenant.tenant_id).text(tenant.tenant_name));
            });

            $("#deviceGroup").html("");
            $("#deviceGroup").append($("<option>全部</option>").attr("data-id", "1"));
            $.each(data.data.groups, function (index, group) {
                $("#deviceGroup").append($("<option></option>").text(group.group));
            });

            $("#deviceLine").html("");
            $("#deviceLine").append($("<option>全部</option>").attr("data-id", "1"));
            $.each(data.data.lines, function (index, line) {
                $("#deviceLine").append($("<option></option>").text(line.line));
            });
        },
        error: function (e) {
            console.log(e);
        }
    })
}


function loadAdminAlertData() {
    var model = $("#deviceModel").val();
    var type = $("#deviceType").val();
    var tenantId = $("#tenants").find("option:selected").data("id") !== undefined ? "" : $("#tenants").find("option:selected").val();
    var group = $("#deviceGroup").find("option:selected").data("id") !== undefined ? "" : $("#deviceGroup").find("option:selected").text();
    var line = $("#deviceLine").find("option:selected").data("id") !== undefined ? "" : $("#deviceLine").find("option:selected").text();
    if (tenantId==undefined){
        tenantId='';
    }
    $.ajax({
        url: "/admin/device/search",
        type: "get",
        contentType: "application/json",
        data:{
            model: model,
            type: type,
            tenantId:tenantId,
            group: group,
            line: line
        },
        success: function (data) {
            if (data.data.length === 0) {
                swal("无符合结果!", "", "warning");
            } else {
                $("#device_checkbox").empty();
                $.each(data.data, function (index, device) {
                    if (device.device_id != $("#select_device").find("option:selected").data("deviceid")) {
                        var $div;
                        if ($("#device_checkbox").find("#" + device.tenant_id).length != 0) {
                            $div = $("<div></div>").addClass("col-md-6 sie-flex-item item-access").attr("onclick", "addcheckd(this)").append(
                                $("<a></a>").addClass("sie-checkbox checked").attr("data-deviceid", device.device_id).attr("data-devicename", device.device_unique_id).attr("data-tenantid", device.tenant_id).attr("style", "margin-left: 15px;")).append(
                                $("<span></span>").attr("style", "margin-left:5px;").text(device.device_unique_id));
                            $("#device_checkbox").find("#" + device.tenant_id).append($div);
                        } else {
                            $div = $("<div></div>").attr("id", device.tenant_id).addClass("row").attr("style", "margin-top:5px;").append(
                                $("<div></div>").addClass("col-md-12").attr("style", "text-align: left;margin-bottom: 5px;font-weight: 600;").append(
                                    $("<span></span>").text(device.tenant_name + "："))).append(
                                $("<div></div>").addClass("col-md-6 sie-flex-item item-access").attr("onclick", "addcheckd(this)").append(
                                    $("<a></a>").addClass("sie-checkbox checked").attr("data-deviceid", device.device_id).attr("data-devicename", device.device_unique_id).attr("data-tenantid", device.tenant_id).attr("style", "margin-left: 15px;")).append(
                                    $("<span></span>").attr("style", "margin-left:5px;").text(device.device_unique_id)));
                            $("#device_checkbox").append($div);
                        }
                    }
                });
                console.log(data);
            }
        },
        error: function (e) {
            console.log(e);
        }
    })
}

//绑定时间输入框中图片的click事件
function bindDateInputClickEvent(){
    $(".sie-calendar-parent img").bind("click",function(){
        $(this).prev().focus();
    });
}